var LANG = {
	current: 'en',
	current_text: 'English',
	init : function() {
		$('.language').langSelector({
			langs : [{
						text : 'Tiếng Việt',
						value : 'vi',
						img_path: '/css/jquery/language/vi.png'
							}, {
						text : 'English',
						value : 'en',
						img_path: '/css/jquery/language/en.png'
					}, {
						text : '日本',
						value : 'ja',
						img_path: '/css/jquery/language/ja.png'
					}],
			def : {
				text : LANG.current_text,
				value : LANG.current,
				img: true
			},
			callback : function(val) {
				var languages = ['en','vi','ja'];
				var is_correct = false;
				for(i=0;i<languages.length;i++){
					if(val.toLowerCase()==languages[i].toLowerCase()){
						is_correct = true;
						break;
					}
				}
				if(is_correct){
					
					$.ajax({
						type: "POST",
						url: '/admin/change_language/'+val,
						data: {
							'action_name': 'change_language'
						},
						cache: false,
						success: function(data){
							if (data == '1'){
								window.location.reload();
							}
						}
					});
				}
				return false;
			},
		});
	},
	
};